package org.idea.qiyu.framework.export.pdf.controller;

import org.idea.qiyu.framework.export.pdf.utils.InsuranceInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.TemplateEngine;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author linhao
 * @Date created in 7:15 下午 2021/12/23
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Resource
    TemplateEngine templateEngine;

    @GetMapping(value = "/test-html")
    public void test() throws Exception {
//        HtmlTemplate htmlTemplate;
//        // 创建model，需要指定模版引擎和具体的模版，“报告模版”指的是资源目录下/html2pdfTemplate/报告模版.html文件。如果是springboot项目，那么就是在resources文件夹下面
//        Model model = new Model(engine,"报告模版");
//        model.setName("名称");
//        List<InsuranceInfo> insuranceInfos = new ArrayList<>();
//        InsuranceInfo record1 = new InsuranceInfo();
//        record1.setExpirationDate("2021-01-19");
//        record1.setDescription("刹车失灵");
//        insuranceInfos.add(record1);
//        InsuranceInfo record2 = new InsuranceInfo();
//        record2.setExpirationDate("2021-03-06");
//        record2.setDescription("挡风玻璃破裂");
//        insuranceInfos.add(record2);
//        model.setInsuranceInfos(insuranceInfos);
//        //生成pdf，指定目标文件路径
//        model.parse2Pdf("/home/dev/桌面/test.pdf");
    }
}
